#include "Line3D.h"
#include "../GameLib.h"
#include "../Logger.h"

#include "../../OpenGL.h"


Line3D::Line3D(){}
Line3D::Line3D(Point3D &newA, Point3D &newB){
    set(newA,newB);
}
Line3D::Line3D(double xa, double ya, double za, double xb, double yb, double zb){
    set(xa,ya,za,xb,yb,zb);
}
Line3D::~Line3D(){}
Line3D& Line3D::set(Point3D &newA,Point3D &newB){
    a=newA;
    b=newB;
    //Str temp;
    //mainLog.print(Str()<<"The Line's point a is set to: "<<a.toString(temp)<<" and the Line's point b is set to: "<<b.toString(temp));
    return *this;
}
Line3D& Line3D::set(double xa,double ya,double za,double xb,double yb,double zb){
    a.set(xa,ya,za);
    b.set(xb,yb,zb);
    //Str temp;
    //mainLog.print(Str()<<"The Line's point a is set to: "<<a.toString(temp)<<" and the Line's point b is set to: "<<b.toString(temp));
    return *this;
}
double Line3D::length(){
    return a.distance(b);
}
void Line3D::draw(){
    glBegin(GL_LINES);
    a.useAsVertex();
    b.useAsVertex();
    glEnd();
}
void Line3D::draw_width(double width){
    double oldLineWidth;
    oldLineWidth=gameLib.getLineWidth();
    gameLib.setLineWidth(width);
    draw();
    gameLib.setLineWidth(oldLineWidth);
}
void Line3D::draw_color(int hexColor){
    float c[4];
    gameLib.getColorA(c);
    gameLib.setColor(hexColor);
    draw();
    gameLib.setColorA(c);
}
void Line3D::draw_widthColor(double width, int hexColor){
    float c[4];
    gameLib.getColorA(c);
    gameLib.setColor(hexColor);
    draw_width(width);
    gameLib.setColorA(c);
}
